#!/usr/bin/python
#coding=utf-8
'''
double_lineplot by spacexi
version init
'''
import numpy as np
import matplotlib.pyplot as plt
import re
import os
import xlrd
def loadData(flieName):  #读取xlsx文件同时将读取到的文件赋值给x和y并转化为float值
	data = xlrd.open_workbook(flieName)
	table = data.sheets()[0]
	x=table.col_values(0)
	y1=table.col_values(1)
	y2=table.col_values(2)
	x=Tofloat(x)
	y1=Tofloat(y1)
	y2=Tofloat(y2)
	return (x,y1,y2)
	
def Tofloat(x):# 转化为float数值
	for j in range(len(x)):
			x[j]=float(x[j])
	return x

ax = plt.subplot(111) 
ax2 = ax.twinx()
local_label=['k','R-square']#此处按顺序修改图题
(x,y1,y2)=loadData('data.xlsx')
ax.plot(x, y1, color='black',marker='o',linewidth=1,label=local_label[0])
ax.tick_params(direction='in')
ax2.spines['right'].set_color('none')
plt.xlabel('x') #此处修改x轴名称
ax.set_ylabel('y1') #此处修改y1轴名称
#plt.xlim(30,70) # 此处设置x范围范围，若启用该设置请删去最前方#
#ax.set_ylim(30,70) # 此处设置y1范围范围，若启用该设置请删去最前方#
ax.legend(loc="upper left",edgecolor='none')# 此处设置y1图例位置

ax2.plot(x, y2, color='blue',marker='s',linewidth=1,label=local_label[1])
ax2.set_ylabel('y2') #此处修改y2轴名称
#ax2.set_ylim(30,70) # 此处设置y2范围范围，若启用该设置请删去最前方#
ax2.legend(loc="upper right",edgecolor='none')# 此处设置图例位置
ax2.spines['right'].set_color('blue')
ax2.tick_params(direction='in',colors='blue')
#ax.set_title('Double Y') # 此处设置图题，若启用该设置请删去最前方#
plt.show()
